package nc.ui.mmpac.sumpickm.handler.body;

import nc.ui.mmf.framework.handler.MMBaseHandler;
import nc.ui.mmf.framework.handler.MMEventHandler;
import nc.ui.pubapp.uif2app.event.IAppEventHandler;
import nc.ui.pubapp.uif2app.event.card.CardBodyBeforeEditEvent;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.mmpac.sumpickm.entity.SumPickmBodyVO;

public class SumPickmCardBodyItemBeforeEditHandler extends MMEventHandler implements
        IAppEventHandler<CardBodyBeforeEditEvent> {

    @Override
    public void handleAppEvent(CardBodyBeforeEditEvent e) {
    	 MMBaseHandler handler = this.getHandler(e.getKey());
         if (!MMValueCheck.isEmpty(handler)) {
             handler.beforeEdit(e);
         }
         else if (this.isEditItem(e)) {
             e.setReturnValue(Boolean.TRUE);
         }
         else {
             e.setReturnValue(Boolean.FALSE);
         }
    }
    private boolean isEditItem(CardBodyBeforeEditEvent e) {
        for (String key : this.EditCol) {
            if (e.getKey().equals(key)) {
                return true;
            }
        }
        return false;

    }
    private String[] EditCol = new String[] {
    		SumPickmBodyVO.VROWNO,
    		SumPickmBodyVO.CDELIVERORGID,SumPickmBodyVO.CDELIVERORGVID,SumPickmBodyVO.COUTSTOCKID,
    		SumPickmBodyVO.VBATCHCODE,SumPickmBodyVO.CLOCATIONID,SumPickmBodyVO.VBNOTE
    		
    };

    @Override
    public void initMap() {
        this.putHandler(SumPickmBodyVO.CDELIVERORGVID,SumPickmCardBodyItemCdeliverorgvidHandler.class ); 
     	 this.putHandler(SumPickmBodyVO.CDELIVERORGID,SumPickmCardBodyItemCdeliverorgvidHandler.class );  
     	 this.putHandler(SumPickmBodyVO.COUTSTOCKID,SumPickmCardBodyItemCoutstockidHandler.class );    	 
     	 this.putHandler(SumPickmBodyVO.VBATCHCODE,SumPickmCardBodyItemVbatchcodeHandler.class );
     	 this.putHandler(SumPickmBodyVO.CLOCATIONID, SumPickmCardBodyItemClocationidHandler.class);
    }

}
